<%--
  Created by IntelliJ IDEA.
  User: a
  Date: 2024/8/15
  Time: 17:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加图书</title>
    <%
        String base = request.getContextPath()+"/";
        String url = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+base;
    %>
    <base href="<%=url%>">
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //窗体加载后，提交按钮的单击事件，发送异步请求：
            $("[type='button']").click(function () {
                var bname=$("[name='bname']").val();
                var aname=$("[name='aname']").val();
                var cname=$("[name='cname']").val();
                var page=$("[name='page']").val();
                var price=$("[name='price']").val();
                $.get("book/addBook",
                    {"bname":bname,"aname":aname,"cname":cname,"page":page,"price":price},
                    function (str) {
                    JSON.stringify(str);
                    if(str){
                        alert("添加成功");
                    }else{
                        alert("添加失败");
                    }
                });
            });
        });
    </script>
</head>
<body>
    <a href="index.jsp">返回</a>
    <h1>增加图书</h1>
    书名：<input type="text" name="bname"/><br/>
    作者：<input type="text" name="aname"/><br/>
    出版社：<input type="text" name="cname"/><br/>
    页数：<input type="text" name="page"/><br/>
    价格：<input type="text" name="price"/><br/>
     <input type="button" value="提交"/><br/>

</body>
</html>
